#include <bits/stdc++.h>

using namespace std;

#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

#define in read()
#define eb emplace_back
#define fi first
#define se second

int read() {
	int x; scanf("%d", &x); return x;
}

const int N = 1e6 + 10;

using pii = pair < int, int >;

int Q;
int lst;

tuple < int, int, int > a[10], b[10];
int tot;

int main() {
	Q = in;
	while(Q--) {
		int op, x, y, w; op = in, x = in ^ lst, y = in ^ lst;
		if(op == 1) {
			w = in ^ lst; a[++tot] = { w, x, y };
			sort(a + 1, a + tot + 1, greater <tuple < int, int, int > >());
			int tt = 0, cx = -1, cy = -1;
			vector < pii > pot;
			rep(i, 1, tot) {
				if(tt == 0) b[++tt] = a[i], tie(cx, cy) = { get<1>(a[i]), get<2>(a[i]) };
				else {
					bool ok = 0; int tw, x, y; tie(tw, x, y) = a[i];
					if(cx != -1 && x != cx) ok = 1;
					if(cy != -1 && y != cy) ok = 1;
					for(auto v : pot) if(v.fi != x && v.se != y) ok = 1;
					if(ok) {
						b[++tt] = a[i];
						if(cx != -1 && x != cx) pot.eb(cx, y), cx = -1;
						if(cy != -1 && y != cy) pot.eb(x, cy), cy = -1;
						vector < pii > tpot;
						for(auto v : pot) if(v.fi == x || v.se == y) tpot.eb(v);
						pot.swap(tpot);
					}
				}
			}
			tot = tt; rep(i, 1, tot) a[i] = b[i];
		} else {
			int ans = 0;
			rep(i, 1, tot) if(get<1>(a[i]) != x && get<2>(a[i]) != y) ans = max(ans, get<0>(a[i]));
			printf("%d\n", lst = ans);
		}
	}
}
